Skip to content

Improved Form Validation Docs #2058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 30, 2012
Merged

Conversation

rdohms
Copy link
Contributor

@rdohms rdohms commented Dec 22, 2012

Added info about adding constraints to each field as opposed to only using DefaultOptions.
Also added a tip about settings validation groups.

Added info about adding constraints to each field as opposed to only using DefaultOptions.
Also added a tip about settings validation groups.
``constraints`` option, which accepts a single constraint or an array
of them.

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be .. code-block:: php

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wouterj this is the recommendation in the "contributing page": The :: shorthand is preferred over .. code-block:: php to begin a PHP code block;

http://symfony.com/doc/master/contributing/documentation/overview.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdohms yes, I know (I wrote those standards). But not in this case. The :: shorthand indicates a code-block in the indented lines after and replaces :: with :. For instance, if you have a sentence like this:

Look what this code does:

.. code-block:: php

    // some php code

You should turn it into:

Look what this code does::

    // some php code

Those are rendered the same. But if you have a code block without a sentence you shouldn't use this shorthand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wouterj ok i'll fix it. But i think that should be said in the guide as well. Also it feels like a double standard.

@rdohms
Copy link
Contributor Author

rdohms commented Dec 27, 2012

@wouterj changes made.

@@ -1581,6 +1581,39 @@ an array of data, instead of an object. In most cases, it's better - and
certainly more robust - to bind your form to an object. But for simple forms,
this is a great approach.

.. versionadded:: 2.1
It is now possible to add constraints directly to the fields using the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is misleading. validation_constraint was also applying on the field directly. The difference is that it was impossible to add several constraints

weaverryan added a commit that referenced this pull request Dec 30, 2012
@weaverryan weaverryan merged commit 8aeb9cf into symfony:2.1 Dec 30, 2012
weaverryan added a commit that referenced this pull request Dec 30, 2012
…raints` option on individual forms, which is much easier than adding things globally, as we did in 2.0
weaverryan added a commit that referenced this pull request Dec 30, 2012
@weaverryan
Copy link
Member

Hi Rafael!

This is an excellent note to add for 2.1 - it wasn't previously documented. And actually, the docs above this are leftover from 2.0, where it was much more work (involving a CollectionConstraint) to apply validation to individual fields. So, I've removed that old section entirely and replaced it with your new documentation. I've also updated the reference section, which still doesn't have all the global "form" options, to include this.

Thanks so much for this addition! If anyone sees that I've made a mistake in my commits, please let me know!

@rdohms rdohms deleted the form-validation-update branch December 31, 2012 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants